package com.hao1st.service1.biz.indexdemo.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class IndexDemoController {

    /**
     * 浏览器访问
     * @return
     */
    @GetMapping("/index")
    public String index(){
        return "您访问的是service1的index";
    }

    /**
     * rpc访问
     * @return
     */
    @PostMapping("/pindex")
    public String postIndex(HttpServletRequest request, @RequestHeader HttpHeaders httpHeaders) {

        List<String> cookie = httpHeaders.get("cookie");
        cookie.forEach(s -> log.info("cookie：{}", s));
        return "您访问的是service1的postIndex，会话ID是" + request.getSession().getId();
    }
}
